var Arrow = Composite.extend({
    init: function(start, end, startPolygon, endPolygon){
        this._start = start;
        this._end = end;
        this._line = new Line(this._start, this._end);
        this._startPolygon = startPolygon;
        this._endPolygon = endPolygon;
        this._super(this.getShapes());
        this._updateStartPolygon();
        this._updateEndPolygon();
    },
    getShapes: function(){
        var shapes = new Array();
        shapes.push(this._line);
        if(this._startPolygon){
            shapes.push(this._startPolygon);
        }
        if(this._endPolygon){
            shapes.push(this._endPolygon);
        }
        return shapes;
    },
    setStart: function(start){
        this._start = start;
        this._line.setStart(start);
        this._updateStartPolygon();
        this._updateEndPolygon();
    },
    setEnd: function(end){
        this._end = end;
        this._line.setEnd(end);
        this._updateStartPolygon();
        this._updateEndPolygon();
    },
    getStart: function(){
        return this._start;
    },
    getEnd: function(){
        return this._end;
    },
    setStartPolygon: function(startPolygon){
        this._startPolygon.setPartOfComposite(false);
        this._startPolygon = startPolygon;
        this._startPolygon.setPartOfComposite(true);
        this._updateStartPolygon();
    },
    setEndPolygon: function(endPolygon){
        this._endPolygon.setPartOfComposite(false);
        this._endPolygon = endPolygon;
        this._endPolygon.setPartOfComposite(true);
        this._updateEndPolygon();
    },
    _updateStartPolygon: function(){
        if(this._startPolygon != null){
            this._startPolygon.setOrigin(this._start);
            this._startPolygon.resetRotation();
            this._startPolygon.rotate(270-this._line.getXAxisRadius());
        }
    },
    _updateEndPolygon: function(){
        if(this._endPolygon != null){
            this._endPolygon.setOrigin(this._end);
            this._endPolygon.resetRotation();
            this._endPolygon.rotate(90-this._line.getXAxisRadius());
        }
    }
});